﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace GXRTBTC.PublicClassLibrary.Model
{
    #region 结构体
    /// <summary>
    /// 电源复位器获取参数结构体
    /// Pack = 1时不补位
    /// Pack = 4 时表示按4补位，为了和C++builder兼容
    /// </summary>
    [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
    [Serializable]
    public struct HjGetDate
    {
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
        public string StationCode;              //台站编号
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
        public string SystemType;               //系统类型Restorer
        public byte DevAddr;                    //设备地址
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
        public string CmdType;                  //命令类型GetRestorerData
        public short ParamByteCount;            //参数字节长度
        public short CheckSum;                  //校验和，前面所有数据按字节相加
    }

    /// <summary>
    /// 电源复位器控制结构体
    /// Pack = 1时不补位
    /// Pack = 4 时表示按4补位，为了和C++builder兼容
    /// </summary>
    [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
    [Serializable]
    public struct HjYjCmd
    {
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
        public string StationCode;              //台站编号
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
        public string SystemType;               //系统类型Restorer
        public byte DevAddr;                    //设备地址
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
        public string CmdType;                  //命令类型ControlCmd
        public short ParamByteCount;            //参数字节长度
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
        public string Params;                    //命令参数PowerOn、PowerOff、Reset
        public short CheckSum;                  //校验和，前面所有数据按字节相加
    }

    /// <summary>
    /// 复位器数据结构体
    /// Pack = 1时不补位
    /// Pack = 4 时表示按4补位，为了和C++builder兼容
    /// </summary>
    [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
    [Serializable]
    public struct ChannelState
    {
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
        public string StationCode;              //台站编号
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
        public string SystemType;               //系统类型Restorer
        public byte DevAddr;                    //设备地址
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
        public string CmdType;                  //命令类型
        public short ParamByteCount;            //参数字节长度
        public bool CommSucc;                   //通信正常否，false不正常
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
        public Channel[] Channels;              //命令参数通道明细
        public short CheckSum;                  //校验和，前面所有数据按字节相加
    }

    /// <summary>
    /// 通道数据
    /// Pack = 1时不补位
    /// Pack = 4 时表示按4补位，为了和C++builder兼容
    /// </summary>
    [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
    [Serializable]
    public struct Channel
    {
        public byte Output;         //输出状态，0无，1有
        public byte ResetStatus;    //复位状态, 0未复位，非0复位中
        public byte ResetDuration;  //通道复位时长
        public byte DetectTime;     //复位检测时长
        public byte ManualResetEn;  //人工复位允许
        public byte AutoResetEn;    //自动复位允许
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
        public byte[] Signature;      //特征符.其中1-4字符为特征码字符，5为'\0'
    }
    #endregion
}
